#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull hs;
ull ans[100010];
string s;
map<ull,ll> cnt;
const ll seed=131;
void gethash(){
    hs=0;
    ll len=s.length();
    for(int i=len-1;i>=0;i--){
        hs=hs*seed+s[i];
        cnt[hs]++;
    }
}
int main()
{
    IOS;
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s;
        gethash();
        ans[i]=hs;
    }
    for(int i=1;i<=n;i++){
        cout<<cnt[ans[i]]<<endl;
    }
    cout<<endl;
    getchar();
    getchar();
    return 0;
}
